<?php
/*
	分销中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$this->session('footernav','');
if($_RQ['op']=='main'){
	$this->setting=$this->plugin_setting('sanset');
	if($this->setting['mid']!=$_SESSION['uid']){
		exi('你不是三方管理员！','error','/index/');
	}
	$return['setting']=$this->plugin_setting('page_setting');
	$diytitle=array('tagent','tshop','tmyshop','tcenter','tbecome','balance_button','tcommission','tcommission1','commission_total','commission_1','balance_total','balance_1','commission_1_1','commission_0','balance_2','balance_3','balance_pay','tcommission_detail','torder','tdown','tmydown','area_title','commission_area');
	foreach($diytitle as $v){
		$return['setting'][$v]=$return['setting'][$v.'2']?:$return['setting'][$v];
	}
	$return['tagent']=$tagent;
	set_html('title',$return['setting']['title']?:'三方中心');
	$member=model('core/member')->basic($_SESSION['uid']);
	$return['ordernum']=0;
	$return['member']=$member;
	$data=array();
	//已结算佣金
	$data['balance_total']=$this->sum('balance',array('mid'=>$_SESSION['uid']),'money');
	$data['balance_num']=$this->count('balance',array('mid'=>$_SESSION['uid']));
	//待结算佣金
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1,'isxuni'=>0);
	/*if($this->setting['balance_day']){
		//结算天数
		$time=TIMESTAMP-intval($this->setting['balance_day'])*86400;
		$params['complete_time <']=$time;
	}*/
	$data['commission_1']=$this->sum('commission',$params,'money');
	$data['commission_1num']=$this->count('commission',$params,'id');
	$data['commission_total']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'money');
	$data['commission_num']=$this->count('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
	$data['commission_area']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'level'=>16),'money');
	$data['commission_xuni']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'level'=>array(18,19)),'money');
	$return['data']=$data;
	$htmls=array(
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'总额/数量','datas'=>array(
			array('title'=>'总佣金','num'=>2,'data'=>array($data['commission_total'],$data['commission_num'])),
			array('title'=>'已结算','yuan'=>1,'num'=>2,'data'=>array($data['balance_total'],$data['balance_num'])),
			array('title'=>'待结算','yuan'=>1,'num'=>2,'data'=>array($data['commission_1'],$data['commission_1num'])),
			array('title'=>'团队人数','num'=>2,'data'=>array($allmember_num,$allmember_num)),
		)),
	);
	if($_SESSION['os']=='windows'){
		$return['htmls']=$htmls;
	}
	exi($return);
}
?>